package com.leyou.search.pojo;

import lombok.Data;

import java.util.Map;

/**
 * @Author: Rose
 * @Date: 2021/4/3 13:30
 * @description ${description}
 * @version: 1.0.0
 */
@Data
public class SearchRequest {

    // 搜索字段
    private String key;

    // 当前页
    private Integer page;

    // 搜索字段
    private Map<String, String> filter;


    // 默认每页显示的条数, 不从页面接收,而是固定大小.
    private static final Integer DEFAULT_ROWS = 20;

    // 默认页
    private static final Integer DEFAULT_PAGE = 1;

    public Integer getPage() {
        if (page == null) {
            return DEFAULT_PAGE;
        }
        // 获取页码时,做一些校验, 不能小于1
        return Math.max(DEFAULT_PAGE, page);
    }

    public Integer getSize() {
        return DEFAULT_ROWS;
    }

    public Map<String, String> getFilter() {
        return filter;
    }

    public void setFilter(Map<String, String> filter) {
        this.filter = filter;
    }
}
